using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using Comteck.Winforms.Forms;
using Comteck.Timing;

namespace Comteck.Winforms.Dialog {
  public partial class FrmDateDialog : FrmDialogBase {
    [Browsable(false)]
    public Action<DateTime> ImportAction { get; set; }

    public DateTime Date { get; set; } = Clock.Now.Date;

    public FrmDateDialog() {
      InitializeComponent();
    }

    private void FrmDateDialog_Load(object sender, EventArgs e) {
      this.dtDate.DateTime = this.Date;
    }

    private void btnConfirm_Click(object sender, EventArgs e) {
      this.Date = this.dtDate.DateTime.Date;

      this.ImportAction?.Invoke(this.Date);

      this.DialogResult = DialogResult.OK;
    }

    private void btnClose_Click(object sender, EventArgs e) {
      this.Close();
    }
  }
}
